package com.genius.smsdao.dormitorymanage.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.genius.smsbase.Domain.BaseEntity;

import javax.persistence.*;
import java.util.List;

/**
 * @Entity:Apartment 公寓实体类
 * 对应数据库表名：apartment
 * @author：
 */
@Entity
@Table(name = "apartment")
public class Apartment extends BaseEntity<Long> {

    @Column
    private String name;

    //公寓到宿舍一对多关系
    @JsonIgnoreProperties(value = "apartment",allowSetters = true)
    @OneToMany(mappedBy = "apartment",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.EAGER)
    private List<Dormitory> dormitoryList;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Dormitory> getDormitoryList() {
        return dormitoryList;
    }

    public void setDormitoryList(List<Dormitory> dormitoryList) {
        this.dormitoryList = dormitoryList;
    }

    @Override
    public String toString() {
        return "Apartment{" +
                "name='" + name + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", id=" + id +
                '}';
    }
}
